<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">物料编号</label>
        <el-input v-model.trim="query.productNo" clearable placeholder="物料编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <label class="el-form-item-label">标签号</label>
        <el-input v-model.trim="query.serialNo" clearable placeholder="标签号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <label class="el-form-item-label">物料描述</label>
        <el-input v-model="query.productDescription" clearable placeholder="物料描述" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <label class="el-form-item-label">客户物料编号</label>
        <el-input v-model.trim="query.partnerProductNo" clearable placeholder="客户物料编号" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="标签号">
            <el-input v-model="form.serialNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料编号">
            <el-input v-model="form.productNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料描述">
            <el-input v-model="form.productDescription" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户物料编号">
            <el-input v-model="form.partnerProductNo" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="客户">
            <el-input v-model="form.receiverName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="物料类型（1-成品，2-容器）">
            <el-input v-model="form.materialType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="0-RPA物料待检，1-良品，2-不良品">
            <el-input v-model="form.quality" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="数量">
            <el-input v-model="form.qty" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱数">
            <el-input v-model="form.nb" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="净重">
            <el-input v-model="form.netWeight" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="重量单位(KGM)">
            <el-input v-model="form.weightUom" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="母托编码">
            <el-input v-model="form.parentPalletCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="储位编码（LT001-001-001）">
            <el-input v-model="form.storageCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="储位库区类型">
            <el-input v-model="form.storageType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="生产日期">
            <el-input v-model="form.creationDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="入库时间">
            <el-input v-model="form.inboundTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="更新时间">
            <el-input v-model="form.updateTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="超期时间">
            <el-input v-model="form.overdueTime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="0-未冻结，1-已冻结">
            <el-input v-model="form.frozen" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="1-正常，2-超期">
            <el-input v-model="form.status" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="母托ID">
            <el-input v-model="form.parentPalletId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="标记原因（冻结原因）">
            <el-input v-model="form.remarksReason" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="标记人员">
            <el-input v-model="form.remarksName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="解冻原因">
            <el-input v-model="form.unfreezeReason" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="解冻人员">
            <el-input v-model="form.unfreezeName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否已贴标: 0-未贴标，1-已贴标">
            <el-input v-model="form.isLabel" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="是否已满箱: 0-未满箱，1-已满箱">
            <el-input v-model="form.isFullBox" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="批次编号">
            <el-input v-model="form.batchCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="母托类型">
            <el-input v-model="form.parentPalletType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="使用率">
            <el-input v-model="form.useRate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="port口信息">
            <el-input v-model="form.portLocation" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="库区类型:立库,雨棚区一楼">
            <el-input v-model="form.areaType" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <!-- <el-table-column type="selection" width="55" /> -->
        <el-table-column prop="serialNo" label="标签号" />
        <el-table-column prop="productNo" label="物料编号" />
        <el-table-column prop="productDescription" label="物料描述" />
        <el-table-column prop="partnerProductNo" label="客户物料编号" />
        <el-table-column prop="receiverName" label="客户" />
        <!-- （1-成品，2-容器） -->
        <el-table-column prop="materialType" label="物料类型" />
        <!-- 0-RPA物料待检，1-良品，2-不良品 -->
        <el-table-column prop="quality" label="品质" />
        <el-table-column prop="qty" label="数量" />
        <el-table-column prop="nb" label="箱数" />
        <el-table-column prop="netWeight" label="净重" />
        <el-table-column prop="weightUom" label="重量单位(KGM)" />
        <el-table-column prop="parentPalletCode" label="母托编码" />
        <el-table-column prop="storageCode" label="储位编码" />
        <el-table-column prop="storageType" label="储位库区类型" />
        <el-table-column prop="creationDate" label="生产日期" />
        <el-table-column prop="inboundTime" label="入库时间" />
        <el-table-column prop="updateTime" label="更新时间" />
        <el-table-column prop="overdueTime" label="超期时间" />
        <el-table-column prop="frozen" label="冻结状态">
          <template slot-scope="scope">
            {{ dict.label.material_frozen[scope.row.frozen] }}
          </template>
        </el-table-column>
        <!-- 1-正常，2-超期 -->
        <el-table-column prop="status" label="物料状态" />
        <el-table-column prop="parentPalletId" label="母托ID" />
        <el-table-column prop="remarksReason" label="标记原因" />
        <el-table-column prop="remarksName" label="标记人员" />
        <el-table-column prop="unfreezeReason" label="解冻原因" />
        <el-table-column prop="unfreezeName" label="解冻人员" />
        <el-table-column prop="isLabel" label="是否已贴标" />
        <el-table-column prop="isFullBox" label="是否已满箱" />
        <el-table-column prop="batchCode" label="批次编号" />
        <el-table-column prop="parentPalletType" label="母托类型" />
        <el-table-column prop="useRate" label="使用率" />
        <el-table-column prop="portLocation" label="port口信息" />
        <el-table-column prop="areaType" label="库区类型" />
        <!-- <el-table-column v-if="checkPer(['admin','inventoryHistory:edit','inventoryHistory:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column> -->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudInventoryHistory from '@/api/work/storageHistory'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
// import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, serialNo: null, productNo: null, productDescription: null, partnerProductNo: null, receiverName: null, materialType: null, quality: null, qty: null, nb: null, netWeight: null, weightUom: null, parentPalletCode: null, storageCode: null, storageType: null, creationDate: null, inboundTime: null, updateTime: null, overdueTime: null, frozen: null, status: null, parentPalletId: null, remarksReason: null, remarksName: null, unfreezeReason: null, unfreezeName: null, isLabel: null, isFullBox: null, batchCode: null, parentPalletType: null, useRate: null, portLocation: null, areaType: null }
export default {
  name: 'StorageHistory',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['material_frozen'],
  cruds() {
    return CRUD({ title: 'inventoryHistory', url: 'api/inventoryHistory', idField: 'id', sort: 'id,desc', crudMethod: { ...crudInventoryHistory },
      optShow: {
        reset: true,
        add: false,
        del: false,
        edit: false,
        download: true
      }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'inventoryHistory:add', 'otherUser'],
        edit: ['admin', 'inventoryHistory:edit', 'otherUser'],
        del: ['admin', 'inventoryHistory:del', 'otherUser']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'serialNo', display_name: '标签号' },
        { key: 'productNo', display_name: '物料编号' },
        { key: 'productDescription', display_name: '物料描述' },
        { key: 'partnerProductNo', display_name: '客户物料编号' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
